<template>
	<!--  自提地址选择-->
	<!-- <view v-if="pickupList && pickupList[0]">
		<u-radio-group v-if="pickForm.pk_id" v-model="checkPick" :active-color="vuex_config.themeColor1">
			<u-cell-group>
				<u-cell-item title="使用自提地址" :arrow="false" @click="goSelect"></u-cell-item>
				<u-cell-item :arrow="false" @click="goChange()">
					<view slot="icon" class="pick_icon iconfont iconfont-e769"></view>
					<view slot="title">
						<view class="pick_title">{{ pickForm.name }} {{ pickForm.phone }}</view>
						<view class="pick_title pick_t_address u-line-1">{{ pickForm.address }}</view>
					</view>
					<u-radio slot="right-icon" :name="1"></u-radio>
				</u-cell-item>
			</u-cell-group>
		</u-radio-group>
		<view v-else class="go_select" @click="goSelect">请选择自提地址</view>
	</view> -->
	<view class="sww-address-box" v-if="pickupList && pickupList[0]" @click="goSelect()">
		<u-icon name="e769" size="44" color="#666666" custom-prefix="iconfont"></u-icon>
		<block v-if="pickForm.pk_id?true:false">
			<view class="s-a-content">
				<view class="s-a-top">
					<text class="">{{pickForm.name}}</text>
					<text class="u-m-l-24">{{pickForm.phone}}</text>
				</view>
				<view class="s-a-detail u-m-t-6">
					{{pickForm.address}}
				</view>
			</view>
			<u-checkbox v-model="checkPick" :active-color="vuex_config.themeColor1" shape="circle" @change="goChange">
			</u-checkbox>
		</block>
		<block v-else>
			<view class="s-a-content">请选择自提地址</view>
		</block>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				bol: 1,
				pickupList: [
					// {name:'自提1',address:'xxx',phone:'xxx11',pk_id:1},
				],
				pickForm: {}, // 当前显示的自提地址
				checkPick: false, // 是否选择了当前显示d的自提地点
				prodId: null,
				index: 0,
				dataArr: []
			};
		},
		mounted() {
			uni.removeStorage({
				key: 'pickForm'
			})
		},

		methods: {
			$show() {
				uni.getStorage({
					key: 'pickForm',
					success: (res) => {
						if (res.data && res.data.pk_id) {
							this.checkPick = true
							this.$emit('changPick', true);
							this.pickForm = res.data
						}
					}
				});
			},
			// 获取自提地址
			getPickupList(prodIdList) {
				this.dataArr = prodIdList
				this.onGetProductDeliveryList({
					pk_id: prodIdList[this.index],
					page_size: 100
				})
			},
			
			// 均哥取其中一个商品的自提地址
			onGetProductDeliveryList(params) {
				this.$loading();
				this.$resPost('GetProductDeliveryList', params)
					.then(({
						data
					}) => {
						this.$hide();
						if (data[0]) {
							this.pickupList = data;
							this.prodId = params.pk_id
						} else {
							this.index += 1
							if(this.index < this.dataArr.length){
								this.onGetProductDeliveryList({
									pk_id: this.dataArr[this.index],
									page_size: 100
								})
							}
						}

					})
					.catch(() => {
						this.$hide();
					});

			},

			// 切换选择自提地址
			goChange(e) {
				this.$emit('changPick', e.value);
			},
			goSelect() {
				this.$linkTo(`/package/product/local/pickUpAddress/index?prodId=${this.prodId}`);
			}
		}
	};
</script>

<style scoped lang="scss">
	.pick_icon {
		color: #666;
		font-size: 44rpx;
		margin-right: 24rpx;
	}

	.pick_title {
		font-size: 28rpx;
		line-height: 34rpx;

		&.pick_t_address {
			margin-top: 2rpx;
			margin-right: 6rpx;
		}
	}

	.go_select {
		padding: 30rpx;
		color: #666;
		border-bottom: 1px solid #f5f5f5;
		background-color: #fff;
	}

	.sww-address-box {
		width: 100%;
		background-color: #ffffff;
		padding: 30rpx 0rpx 30rpx 30rpx;
		display: flex;
		align-items: center;
		border-bottom: 1rpx solid #f5f5f5;

		.s-a-content {
			flex: 1;
			overflow: hidden;
			margin: 0 24rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			font-size: 26rpx;
			color: #666666;
		}
	}
</style>
